<template>
  <view class="container">
    <view class="news-detail">
      <view class="news-detail-title">
        {{ news.title }}
      </view>
      <rich-text
        class="content"
        :nodes="news.content"
      />
      <br>
      <view class="news-item-date">
        {{ news.createTime}}
      </view>
    </view>
  </view>
</template>

<script>
import {news} from "@/api/index/newDetail"
export default {
  data(){
    return{
      news:{
        title: '',
        content: '',
        id: null
      }
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options){
  // 加载公告详情
    news(options.id)
      .then(({data})=> {
        console.log(data);
        data.content = data.content.replace(/width=/gi, 'sss=')
        data.content = data.content.replace(/height=/gi, 'sss=')
        data.content = data.content.replace(/ \/>/gi, ' style="max-width:100% !important;display:block;" />')
        this.news= data
      })
}
}

</script>

<style scoped lang="scss">
.news-detail {
  padding: 20rpx;
  .news-detail-title {
    font-size: 32rpx;
    font-weight: bold;
    line-height: 50rpx;
    padding: 20rpx;
  }
  .news-detail-text {
    font-size: 28rpx;
    line-height: 46rpx;
    text-align: justify;
    text-justify: inter-ideograph;
    margin-top: 20rpx;
  }
}
.content {
  :deep(img) {
    display: block;
    width: 100%;
    height: auto;
  }
}

</style>
